﻿using Masuit.Tools.Systems;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Canteen.Core.Models
{
    public class User : BaseEntity
    {
        public User(string phone)
        {
            Code = SnowFlake.GetInstance().GetUniqueId();
            Phone = phone;
        }

        [StringLength(12), Required]
        [Column(TypeName = "VARCHAR(12)")]
        public string Code { get; set; }//唯一标识

        [MaxLength(32)]
        public string Name { get; set; }

        public int? Sex { get; set; }//性别，1男性，2女性，0未知
        [MaxLength(64)]//AES密钥加密后是44位
        public string IdCard { get; set; }//身份证号码
        [MaxLength(256)]
        public string HeadImgUrl { get; set; }//用户头像

        [StringLength(32)]//AES密钥加密后是24位
        public string Phone { get; set; }//手机号码
        [MaxLength(256)]//AES密钥加密
        public string Email { get; set; }//邮箱
        [MaxLength(256)]//AES密钥加密
        public string Account { get; set; }//账号
        [MaxLength(32)]//MD5加密后是32位
        public string PassWord { get; set; }//密码

        [MaxLength(28)]
        public string WeChatUnionid { get; set; }//微信用户统一标识
        public int Logins { get; set; }

        [Column(TypeName = "MONEY")]
        public decimal Wallet { get; set; }//余额

        public List<ShopOrder> ShopOrderList { get; set; } = new List<ShopOrder>();
    }
}
